{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "第一周作业：\n",
    "在Capital Bikeshare 提供的数据进行回归分析"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 54,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np # linear algebra\n",
    "import pandas as pd # data processing, CSV file I/O\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "import seaborn as sns\n",
    "#color = sns.color_palette()\n",
    "\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 55,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>instant</th>\n",
       "      <th>dteday</th>\n",
       "      <th>season</th>\n",
       "      <th>yr</th>\n",
       "      <th>mnth</th>\n",
       "      <th>holiday</th>\n",
       "      <th>weekday</th>\n",
       "      <th>workingday</th>\n",
       "      <th>weathersit</th>\n",
       "      <th>temp</th>\n",
       "      <th>atemp</th>\n",
       "      <th>hum</th>\n",
       "      <th>windspeed</th>\n",
       "      <th>casual</th>\n",
       "      <th>registered</th>\n",
       "      <th>cnt</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>1</td>\n",
       "      <td>2011-01-01</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>6</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.344167</td>\n",
       "      <td>0.363625</td>\n",
       "      <td>0.805833</td>\n",
       "      <td>0.160446</td>\n",
       "      <td>331</td>\n",
       "      <td>654</td>\n",
       "      <td>985</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2</td>\n",
       "      <td>2011-01-02</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>0.363478</td>\n",
       "      <td>0.353739</td>\n",
       "      <td>0.696087</td>\n",
       "      <td>0.248539</td>\n",
       "      <td>131</td>\n",
       "      <td>670</td>\n",
       "      <td>801</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>3</td>\n",
       "      <td>2011-01-03</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.196364</td>\n",
       "      <td>0.189405</td>\n",
       "      <td>0.437273</td>\n",
       "      <td>0.248309</td>\n",
       "      <td>120</td>\n",
       "      <td>1229</td>\n",
       "      <td>1349</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>4</td>\n",
       "      <td>2011-01-04</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>2</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.200000</td>\n",
       "      <td>0.212122</td>\n",
       "      <td>0.590435</td>\n",
       "      <td>0.160296</td>\n",
       "      <td>108</td>\n",
       "      <td>1454</td>\n",
       "      <td>1562</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>5</td>\n",
       "      <td>2011-01-05</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>1</td>\n",
       "      <td>0</td>\n",
       "      <td>3</td>\n",
       "      <td>1</td>\n",
       "      <td>1</td>\n",
       "      <td>0.226957</td>\n",
       "      <td>0.229270</td>\n",
       "      <td>0.436957</td>\n",
       "      <td>0.186900</td>\n",
       "      <td>82</td>\n",
       "      <td>1518</td>\n",
       "      <td>1600</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   instant      dteday  season  yr  mnth  holiday  weekday  workingday  \\\n",
       "0        1  2011-01-01       1   0     1        0        6           0   \n",
       "1        2  2011-01-02       1   0     1        0        0           0   \n",
       "2        3  2011-01-03       1   0     1        0        1           1   \n",
       "3        4  2011-01-04       1   0     1        0        2           1   \n",
       "4        5  2011-01-05       1   0     1        0        3           1   \n",
       "\n",
       "   weathersit      temp     atemp       hum  windspeed  casual  registered  \\\n",
       "0           2  0.344167  0.363625  0.805833   0.160446     331         654   \n",
       "1           2  0.363478  0.353739  0.696087   0.248539     131         670   \n",
       "2           1  0.196364  0.189405  0.437273   0.248309     120        1229   \n",
       "3           1  0.200000  0.212122  0.590435   0.160296     108        1454   \n",
       "4           1  0.226957  0.229270  0.436957   0.186900      82        1518   \n",
       "\n",
       "    cnt  \n",
       "0   985  \n",
       "1   801  \n",
       "2  1349  \n",
       "3  1562  \n",
       "4  1600  "
      ]
     },
     "execution_count": 55,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# path to where the data lies\n",
    "#dpath = './data/'\n",
    "data = pd.read_csv(\"day.csv\")\n",
    "\n",
    "#通过观察前5行，了解数据每列（特征）的概况\n",
    "data.head()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 90,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 从原始数据中分离输入特征x和输出y\n",
    "y = data['cnt'].values\n",
    "X = data.drop(['instant','dteday','yr','mnth','cnt','casual','registered'], axis = 1)\n",
    "\n",
    "#用于后续显示权重系数对应的特征\n",
    "columns = X.columns"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 91,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'pandas.core.frame.DataFrame'>\n",
      "Int64Index: 365 entries, 326 to 20\n",
      "Data columns (total 9 columns):\n",
      "season        365 non-null int64\n",
      "holiday       365 non-null int64\n",
      "weekday       365 non-null int64\n",
      "workingday    365 non-null int64\n",
      "weathersit    365 non-null int64\n",
      "temp          365 non-null float64\n",
      "atemp         365 non-null float64\n",
      "hum           365 non-null float64\n",
      "windspeed     365 non-null float64\n",
      "dtypes: float64(4), int64(5)\n",
      "memory usage: 28.5 KB\n"
     ]
    }
   ],
   "source": [
    "#将数据分割训练数据与测试数据\n",
    "from sklearn.model_selection import train_test_split\n",
    "#对y做标准化不是必须\n",
    "# 随机采样20%的数据构建测试样本，其余作为训练样本\n",
    "X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=33, test_size=0.5)\n",
    "X_train.info()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 92,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 数据标准化\n",
    "from sklearn.preprocessing import StandardScaler\n",
    "\n",
    "# 分别初始化对特征和目标值的标准化器\n",
    "ss_X = StandardScaler()\n",
    "ss_y = StandardScaler()\n",
    "\n",
    "# 分别对训练和测试数据的特征以及目标值进行标准化处理\n",
    "X_train = ss_X.fit_transform(X_train)\n",
    "X_test = ss_X.transform(X_test)\n",
    "\n",
    "#对y做标准化不是必须\n",
    "#对y标准化的好处是不同问题的w差异不太大，同时正则参数的范围也有限\n",
    "y_train = ss_y.fit_transform(y_train.reshape(-1, 1))\n",
    "y_test = ss_y.transform(y_test.reshape(-1, 1))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 93,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[0.2932515842002661]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.27326941903928537]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.19753092747566542]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.07459495022905514]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[0.01954228310391952]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[-0.023567817117323246]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.08867327415107143]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[-0.14705715937010455]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[-0.15147309238306772]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                      coef     columns\n",
       "5     [0.2932515842002661]        temp\n",
       "0    [0.27326941903928537]      season\n",
       "6    [0.19753092747566542]       atemp\n",
       "3    [0.07459495022905514]  workingday\n",
       "2    [0.01954228310391952]     weekday\n",
       "1  [-0.023567817117323246]     holiday\n",
       "8   [-0.08867327415107143]   windspeed\n",
       "4   [-0.14705715937010455]  weathersit\n",
       "7   [-0.15147309238306772]         hum"
      ]
     },
     "execution_count": 93,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性回归\n",
    "#class sklearn.linear_model.LinearRegression(fit_intercept=True, normalize=False, copy_X=True, n_jobs=1)\n",
    "from sklearn.linear_model import LinearRegression\n",
    "\n",
    "# 使用默认配置初始化\n",
    "lr = LinearRegression()\n",
    "\n",
    "# 训练模型参数\n",
    "lr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "y_test_pred_lr = lr.predict(X_test)\n",
    "y_train_pred_lr = lr.predict(X_train)\n",
    "\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef\":list((lr.coef_.T))})\n",
    "fs.sort_values(by=['coef'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 94,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LinearRegression on test is 0.5199384829719927\n",
      "The r2 score of LinearRegression on train is 0.5174853016796229\n"
     ]
    }
   ],
   "source": [
    "# 使用r2_score评价模型在测试集和训练集上的性能，并输出评估结果\n",
    "#测试集\n",
    "from sklearn.metrics import r2_score\n",
    "print 'The r2 score of LinearRegression on test is', r2_score(y_test, y_test_pred_lr)\n",
    "#训练集\n",
    "print 'The r2 score of LinearRegression on train is', r2_score(y_train, y_train_pred_lr)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 95,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAekAAAFsCAYAAADos0H8AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUA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XruSaa66hvb2dUaNG8cEPfpDJkydvdd0jRozgnnvuYdddd+Xll1/m2GOP5fTTT3/HBVjf+c53OPnkk7n66qvZsGEDb7zxRp/a+dxzz/Hggw+yZs0aDjroIC6++GKWLl3KnXfeySOPPEJLSwuf/vSnmTt3Lueccw7XXXcdo0ePZsOGDUyfPp0nn3ySI444YlPdDz/8cJ/q2JoeQzozVwIrq+E1EbEYGN/wSiRJTfX73/+eSZMmsWzZMt73vvdx4oknArWQnjdv3qaAXbt2LUuWLOH444/n85//PF/84hc59dRTOf7449+xvMcee4xp06YxZkztx57OPPNMfvnLX261hszkqquuYsGCBeywww6sWLGCVatWsffee2+aZ8qUKZx77rmsW7eOM844g0mTJvWpvTNmzGD48OEMHz6csWPHsmrVKubPn097eztTpkzZ9JqMHTsWgO9///vMnj2b9evXs3LlSp599tlNIX3mmWf2qYae9OqcdERMBCYDj1WjLomIJyPi1ojYvcG1SZK2oY3npF988UXeeuutTeekM5Mrr7ySRYsWsWjRIpYuXcp5553HgQceSHt7O4cffjhXXnkl11577RbL7O4rSDvuuCNvv/32puW/9dZbAMydO5eOjg7a29tZtGgRe+211xbfMz7hhBNYsGAB48eP5+yzz+b222/vU3uHDx++aXjYsGGsX7+ezGTWrFmb2vr888/T1tbGCy+8wA033MD8+fN58sknmTFjxjvq2nnnnftUQ0/qvro7IkYCPwA+m5mvRcQtwF8CWd3/DXBuF8+7ELgQYL/99mtEzVKx6r0it9FX7kqNNGrUKG688UZmzpzJxRdfzMknn8yXvvQlzjrrLEaOHMmKFStoaWlh/fr1jB49mk984hOMHDmSOXPmvGM5xxxzDJdeeimrV69m11135a677uLII48Eaudx29vb+ehHP8q9997LunXrgNoh87Fjx9LS0sKDDz7Iiy9u+YuOL774IuPHj+eCCy7g9ddf54knnuCcc85pSNunT5/OzJkzueyyyxg7diyvvPIKa9as4bXXXmPnnXdm1KhRrFq1ivvvv59p06Y1ZJ1bU1dIR0QLtYCem5k/BMjMVZ2mfx34cVfPzczZwGyA1tb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wCXpsz2bnAk+ndg5xMLsPOKe6gvhY4NWNp2EGo4jYe+M1DxFxNLUsWr31ZzVPVes3gcWZ+bfdzDYw26jZV8315gYspXbMf1F123g16j7ATze7yu6X1PZkrm523Vtpz59S+/T1n8Aq4Gebt4faFay/qG7PDPb2DKbtU9W6BzAfWFLdj67GtwLfqIb/GHiq2kZPAec1u+4u2rHFaw5cS+0DL8AI4K7qPfY4cECza+5ne/5n9X75BfAg8N5m19xDe74LrATWVe+h84BPAZ+qpgdwc9Xep9jKt0FKuNXRnks6bZ9HgT9uds09tOf91A5dP9kpfz68LbaR3YJKklSoQXW4W5KkocSQliSpUIa0JEmFMqQlSSqUIS1JUqEMaUmSCmVIS5JUqP8HTlsxD/5A3YgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0x105275c0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#在训练集上观察预测残差的分布，看是否符合模型假设：噪声为0均值的高斯噪声\n",
    "f, ax = plt.subplots(figsize=(7, 5)) \n",
    "f.tight_layout() \n",
    "ax.hist(y_train - y_train_pred_lr,bins=40, label='Residuals Linear', color='b', alpha=.5); \n",
    "ax.set_title(\"Residuals\") \n",
    "ax.legend(loc='best');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 69,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARgAAADQCAYAAADcQn7hAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJztnXl4VGWyh99K04SELciiEhEcZRiVVSKizChyRXAHXMBlrowjjruOiuKKzHJRGcU743XF64I4oqNwZVFExAUdQNZERGYUBY3IHhAIpNOp+0d3x07Sy0nS3ac7qfd58qRPp8/5funkVH9f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YFRwJsua3IVCXQAfBZYq6qPuKijfSi6KSI5wGkk6H5psJm8IvI6gYhJZVlOVS12QceXQDawPfjUYlV1pUSoiAwH/ga0B0qAVao6JIXjnwk8SiCi9L+q+udUjV1Nx9+BgQRKE2wGxqvqsy7o+CXwEVBE4P8U4C5VnZtiHT2BFwj8XbKAV1X1Dwm5dkM1MIZhuE+DXSIZhuE+ZmAMw0gaZmAMw0gaZmAMw0gaZmAMw0gaGZ1oZyQWEWkLLAgeHgL4ga3B437BPUSp1jQPuCC4V8fIMCxMbURERO4H9qjqX6o9LwT+byoinpi48VMyjpFcbIlkxEVEjgruZ3oSWAF0EpGSsJ+PEpEpwccHi8gbIrIsWGOkf4TrXRmsjTMvWB/mnijjHCoi34Vlmf4mWFdntYg853Q8wz1siWQ45RjgN6p6tYjE+r/5K/CQqi4O7hCeDUTaONcv+HwZ8KmIzAb2hI8DEJjIgIj0IrDl4iRV3SEiB9VyPMMFzMAYTvlKVT918LrTgG4hwwC0EZEcVS2t9rp5qroTQERmAr8E3o4xziBguqruAAh9r8V4hguYgTGcsjfscQVVyy80C3ssOHMIV3f+hY73Vn9h2HUjOQydjme4gPlgjFoTdLzuFJGuIpIFDA/78bvAdaEDEekd5TKni0ieiOQSqGz3cZxh3wVGhZZGYUskp+MZLmAGxqgrdxBY0iwgUOslxHXAgKAz9nNgTJTzFxGo07MS+Luqroo1mKoWAg8BHwYrr02q5XiGC1iY2kg5InIl0F1Vb3Zbi5FcbAZjGEbSsBmMYRhJw2YwhmEkDTMwhmEkDTMwhmEkDTMwhmEkDTMwhmEkjf8HMyFR92hMLusAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xc13dc18>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "#还可以观察预测值与真值的散点图\n",
    "plt.figure(figsize=(4, 3))\n",
    "plt.scatter(y_train, y_train_pred_lr)\n",
    "plt.plot([-3, 3], [-3, 3], '--k')   #数据已经标准化，3倍标准差即可\n",
    "plt.axis('tight')\n",
    "plt.xlabel('True price')\n",
    "plt.ylabel('Predicted price')\n",
    "plt.tight_layout()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 70,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "C:\\Users\\Administrator\\Anaconda2\\lib\\site-packages\\sklearn\\utils\\validation.py:578: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().\n",
      "  y = column_or_1d(y, warn=True)\n"
     ]
    },
    {
     "data": {
      "text/plain": [
       "array([ 0.2360057 ,  0.04010887, -0.02396816,  0.01950624,  0.07547207,\n",
       "       -0.14690025,  0.28756947,  0.2052462 , -0.15266077, -0.088481  ])"
      ]
     },
     "execution_count": 70,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 线性模型，随机梯度下降优化模型参数\n",
    "# 随机梯度下降一般在大数据集上应用，其实本项目不适合用\n",
    "from sklearn.linear_model import SGDRegressor\n",
    "\n",
    "# 使用默认配置初始化线\n",
    "sgdr = SGDRegressor(max_iter=1000)\n",
    "\n",
    "# 训练：参数估计\n",
    "sgdr.fit(X_train, y_train)\n",
    "\n",
    "# 预测\n",
    "#sgdr_y_predict = sgdr.predict(X_test)\n",
    "\n",
    "sgdr.coef_"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 71,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The value of default measurement of SGDRegressor on test is 0.5162607377095112\n",
      "The value of default measurement of SGDRegressor on train is 0.5178605192698633\n"
     ]
    }
   ],
   "source": [
    "# 使用SGDRegressor模型自带的评估模块(评价准则为r2_score)，并输出评估结果\n",
    "print 'The value of default measurement of SGDRegressor on test is', sgdr.score(X_test, y_test)\n",
    "print 'The value of default measurement of SGDRegressor on train is', sgdr.score(X_train, y_train)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 72,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of RidgeCV on test is 0.49634385026408556\n",
      "The r2 score of RidgeCV on train is 0.5107790980660154\n"
     ]
    }
   ],
   "source": [
    "#岭回归／L2正则\n",
    "#class sklearn.linear_model.RidgeCV(alphas=(0.1, 1.0, 10.0), fit_intercept=True, \n",
    "#                                  normalize=False, scoring=None, cv=None, gcv_mode=None, \n",
    "#                                  store_cv_values=False)\n",
    "from sklearn.linear_model import  RidgeCV\n",
    "\n",
    "#设置超参数（正则参数）范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100]\n",
    "\n",
    "#生成一个RidgeCV实例\n",
    "ridge = RidgeCV(alphas=alphas, store_cv_values=True)  \n",
    "\n",
    "#模型训练\n",
    "ridge.fit(X_train, y_train)    \n",
    "\n",
    "#预测\n",
    "y_test_pred_ridge = ridge.predict(X_test)\n",
    "y_train_pred_ridge = ridge.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print 'The r2 score of RidgeCV on test is', r2_score(y_test, y_test_pred_ridge)\n",
    "print 'The r2 score of RidgeCV on train is', r2_score(y_train, y_train_pred_ridge)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 73,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYsAAAEKCAYAAADjDHn2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xl8VPW9//HXJ5ksZGFNwr4qu6yJLG6FSxdqVeoGIlDxaoF6udpf29va5V7v1dtWa+u1LlWU2iq4gFpbbbVYFXApKAmyCmEViCwJOySQkOT7+2MOGmMgE8jJmWTez8djHs6cOTPzzhF45yzz/ZpzDhERkdO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sKzkx3yXvM3wuXxhnNupZl9SHhE0i3Ae6f4nGKgv5nlee8zoZZcvwNeNLNrCY8IW1zludFeBhFfadRZkQiYWZoLz4zWhvDexoVekTQj/A/4hd65jkje66hzLq2ecr0NjHPOHaiP9xM5Fe1ZiETmr2bWEkgE7nLO7QZwzh0zszsIz3O8vSEDeYfK7lNRSEPQnoWIiNRKJ7hFRKRWKgsREamVykJERGqlshARkVqpLEREpFYqCxERqdX/Bxo75nt6RyxVAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xc9c8da0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('alpha is:', 100.0)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>[0.29244033249899176]</td>\n",
       "      <td>[0.22531033778657303]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>[0.23669589850971356]</td>\n",
       "      <td>[0.1636529291930498]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>[0.2010421090968055]</td>\n",
       "      <td>[0.2206522297389107]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>[0.07528620553686426]</td>\n",
       "      <td>[0.062432184644371835]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>[0.040929960846827734]</td>\n",
       "      <td>[0.08802720407654828]</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>[0.019253452618905785]</td>\n",
       "      <td>[0.016825199581376668]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>[-0.023412449565882183]</td>\n",
       "      <td>[-0.02340350951721692]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>[-0.08879801620492826]</td>\n",
       "      <td>[-0.07352839666514022]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>[-0.14678617685992462]</td>\n",
       "      <td>[-0.14149314610809874]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>[-0.15314632383048182]</td>\n",
       "      <td>[-0.1129040365572308]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   coef_lr              coef_ridge     columns\n",
       "6    [0.29244033249899176]   [0.22531033778657303]        temp\n",
       "0    [0.23669589850971356]    [0.1636529291930498]      season\n",
       "7     [0.2010421090968055]    [0.2206522297389107]       atemp\n",
       "4    [0.07528620553686426]  [0.062432184644371835]  workingday\n",
       "1   [0.040929960846827734]   [0.08802720407654828]        mnth\n",
       "3   [0.019253452618905785]  [0.016825199581376668]     weekday\n",
       "2  [-0.023412449565882183]  [-0.02340350951721692]     holiday\n",
       "9   [-0.08879801620492826]  [-0.07352839666514022]   windspeed\n",
       "5   [-0.14678617685992462]  [-0.14149314610809874]  weathersit\n",
       "8   [-0.15314632383048182]   [-0.1129040365572308]         hum"
      ]
     },
     "execution_count": 73,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mse_mean = np.mean(ridge.cv_values_, axis = 0)\n",
    "plt.plot(np.log10(alphas), mse_mean.reshape(len(alphas),1)) \n",
    "\n",
    "#这是为了标出最佳参数的位置，不是必须\n",
    "#plt.plot(np.log10(ridge.alpha_)*np.ones(3), [0.28, 0.29, 0.30])\n",
    "\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()\n",
    "\n",
    "print ('alpha is:', ridge.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 88,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "The r2 score of LassoCV on test is 0.514199316989437\n",
      "The r2 score of LassoCV on train is 0.5172179613453372\n"
     ]
    }
   ],
   "source": [
    "#### Lasso／L1正则\n",
    "# class sklearn.linear_model.LassoCV(eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, \n",
    "#                                    normalize=False, precompute=’auto’, max_iter=1000, \n",
    "#                                    tol=0.0001, copy_X=True, cv=None, verbose=False, n_jobs=1,\n",
    "#                                    positive=False, random_state=None, selection=’cyclic’)\n",
    "from sklearn.linear_model import LassoCV\n",
    "\n",
    "#设置超参数搜索范围\n",
    "alphas = [ 0.01, 0.1, 1, 10,100,100]\n",
    "\n",
    "#生成一个LassoCV实例\n",
    "lasso = LassoCV(alphas=alphas)   \n",
    "\n",
    "#训练（内含CV）\n",
    "lasso.fit(X_train, y_train)  \n",
    "\n",
    "#测试\n",
    "y_test_pred_lasso = lasso.predict(X_test)\n",
    "y_train_pred_lasso = lasso.predict(X_train)\n",
    "\n",
    "\n",
    "# 评估，使用r2_score评价模型在测试集和训练集上的性能\n",
    "print 'The r2 score of LassoCV on test is', r2_score(y_test, y_test_pred_lasso)\n",
    "print 'The r2 score of LassoCV on train is', r2_score(y_train, y_train_pred_lasso)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 89,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYUAAAEKCAYAAAD9xUlFAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMS4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvNQv5yAAAIABJREFUeJzt3Xt0nPWd3/H3V3fbkq+6+CbZBsuAMRiMsM0lgYSQNTRgIDHYYDZJs+GkLdvdbbdd0vQkW3p6tttst6dpyG5JmpMNMjYGAnFYJxAuCbkg2bLBxsYYC8NI8k3y3fJF12//mMfKICRrZOuZR5r5vM7R8Vx+mvnosTSfmef2M3dHREQEICvqACIiMnyoFEREpIdKQUREeqgURESkh0pBRER6qBRERKSHSkFERHqoFEREpIdKQUREeuREHWCwiouLfebMmVHHEBEZUTZt2nTQ3UsGGjfiSmHmzJnU1dVFHUNEZEQxs1gy47T6SEREeqgURESkh0pBRER6qBRERKSHSkFERHqoFEREpEdopWBmPzSzZjPb1s/9ZmbfMbN6M9tqZgvCyiIiIskJ8ziFHwHfBX7cz/23AZXB1yLgH4J/RUac0+1d/PB3H9DW0RV1FEljt1xWxvzy8aE+R2il4O6vm9nMcwxZCvzY45NE15jZeDOb4u77wsokEpZVtTG+/eJOzKJOIumsdGzByC2FJEwDGhOuNwW3qRRkROnudlbVNnDNjAk8+6+ujzqOyAWJckNzX++pvM+BZg+ZWZ2Z1bW0tIQcS2Rwfv/+IT44eJIHF8+IOorIBYuyFJq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afg18K+G+HHdfCPx5wu3NwK3B+PuA7ySMrwM+MfgfVWRwRvwJ8UTOw43EzxbaBRwws18D1wa3P+3u3cB+M3st4XumAC0J1+8NTmeeE9w3l/ipCRJ1A08Fl6uBxJObnb28iXgRAeQC3zWzq4AuYE7C+GbipxsRCZVKQTJRfxPenGsinNPEz2mEmc0C/hK41t2PmNmPzt43gMRzyrQF/3bxh7/DvyB+zqn5xD/Fn0kYXxBkEAmVVh9JJnoduM/MsoP1/J8kfuK63xKfhCbLzMqIT8d41g5gdnB5LHASOBaMu62f58kifpZUgPuDxz+XccC+4JPKg8Sn2DxrDsPjLLmS5vRJQTLRc8S3F2wh/u79P7r7fjN7FriF+Ivve8RnvDoWfM8/Ey+Jl919i5m9SfwMmruB3/XzPCeBy81sU/A49w2Q63vAs2a2jPhZTE8m3PepIINIqHSWVJEEZlbo8Zm2JhH/9HBDUBijiL9Q3xBsi0jmsVrdvXCIcr0OLHX3I0PxeCL90ScFkY96wczGA3nAf3X3/QDuftrMvkV8LtyGVAYKVnH9vQpj3zlBAAAAMElEQVRBUkGfFEREpIc2NIuISA+VgoiI9FApiIhID5WCiIj0UCmIiEgPlYKIiPT4/wiVP9jQEGaCAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<matplotlib.figure.Figure at 0xcb70ef0>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "('alpha is:', 0.01)\n"
     ]
    },
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>coef_lasso</th>\n",
       "      <th>coef_lr</th>\n",
       "      <th>coef_ridge</th>\n",
       "      <th>columns</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>0.294620</td>\n",
       "      <td>[0.29244033249899176]</td>\n",
       "      <td>[0.22531033778657303]</td>\n",
       "      <td>temp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>0.236458</td>\n",
       "      <td>[0.23669589850971356]</td>\n",
       "      <td>[0.1636529291930498]</td>\n",
       "      <td>season</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>0.193056</td>\n",
       "      <td>[0.2010421090968055]</td>\n",
       "      <td>[0.2206522297389107]</td>\n",
       "      <td>atemp</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>0.066776</td>\n",
       "      <td>[0.07528620553686426]</td>\n",
       "      <td>[0.062432184644371835]</td>\n",
       "      <td>workingday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>0.031416</td>\n",
       "      <td>[0.040929960846827734]</td>\n",
       "      <td>[0.08802720407654828]</td>\n",
       "      <td>mnth</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>0.010081</td>\n",
       "      <td>[0.019253452618905785]</td>\n",
       "      <td>[0.016825199581376668]</td>\n",
       "      <td>weekday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>-0.016756</td>\n",
       "      <td>[-0.023412449565882183]</td>\n",
       "      <td>[-0.02340350951721692]</td>\n",
       "      <td>holiday</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>-0.078910</td>\n",
       "      <td>[-0.08879801620492826]</td>\n",
       "      <td>[-0.07352839666514022]</td>\n",
       "      <td>windspeed</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>-0.145074</td>\n",
       "      <td>[-0.14678617685992462]</td>\n",
       "      <td>[-0.14149314610809874]</td>\n",
       "      <td>weathersit</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>-0.139915</td>\n",
       "      <td>[-0.15314632383048182]</td>\n",
       "      <td>[-0.1129040365572308]</td>\n",
       "      <td>hum</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "   coef_lasso                  coef_lr              coef_ridge     columns\n",
       "6    0.294620    [0.29244033249899176]   [0.22531033778657303]        temp\n",
       "0    0.236458    [0.23669589850971356]    [0.1636529291930498]      season\n",
       "7    0.193056     [0.2010421090968055]    [0.2206522297389107]       atemp\n",
       "4    0.066776    [0.07528620553686426]  [0.062432184644371835]  workingday\n",
       "1    0.031416   [0.040929960846827734]   [0.08802720407654828]        mnth\n",
       "3    0.010081   [0.019253452618905785]  [0.016825199581376668]     weekday\n",
       "2   -0.016756  [-0.023412449565882183]  [-0.02340350951721692]     holiday\n",
       "9   -0.078910   [-0.08879801620492826]  [-0.07352839666514022]   windspeed\n",
       "5   -0.145074   [-0.14678617685992462]  [-0.14149314610809874]  weathersit\n",
       "8   -0.139915   [-0.15314632383048182]   [-0.1129040365572308]         hum"
      ]
     },
     "execution_count": 89,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "mses = np.mean(lasso.mse_path_, axis = 1)\n",
    "plt.plot(np.log10(lasso.alphas_), mses) \n",
    "#plt.plot(np.log10(lasso.alphas_)*np.ones(3), [0.3, 0.4, 1.0])\n",
    "plt.xlabel('log(alpha)')\n",
    "plt.ylabel('mse')\n",
    "plt.show()    \n",
    "            \n",
    "print ('alpha is:', lasso.alpha_)\n",
    "\n",
    "# 看看各特征的权重系数，系数的绝对值大小可视为该特征的重要性\n",
    "fs = pd.DataFrame({\"columns\":list(columns), \"coef_lr\":list((lr.coef_.T)), \"coef_ridge\":list((ridge.coef_.T)), \"coef_lasso\":list((lasso.coef_.T))})\n",
    "fs.sort_values(by=['coef_lr'],ascending=False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 2",
   "language": "python",
   "name": "python2"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.14"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
